package com.fishingwithme.domain.common;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.fishingwithme.infrastructure.mapper.LikesMapper;
import com.fishingwithme.infrastructure.utils.CommonUtils;

@Service
public class LikeServiceImpl extends ServiceImpl<LikesMapper, Likes> implements LikeService {
    @Transactional
    @Override
    public Boolean likes(String type, Long targetId) {
        Long userId = CommonUtils.getUserId();
        Integer cnt = baseMapper.likes(type,targetId,userId);
        return cnt > 0;
    }

    @Transactional
    @Override
    public Boolean dislike(String type, Long targetId) {
        Long userId = CommonUtils.getUserId();
        Integer cnt = baseMapper.dislike(type,targetId,userId);
        return cnt > 0;
    }
}
